import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

import global from "./src/global";
import admin from "./src/admin";
import console from "./src/console";

const routes = [].concat(global, admin, console);

const { push, replace } = VueRouter.prototype;

VueRouter.prototype.push = function (location) {
    return push.call(this, location).catch((error) => error);
};
VueRouter.prototype.replace = function (location) {
    return replace.call(this, location).catch((error) => error);
};

const router = new VueRouter({
    mode: process.env.VUE_APP_ROUTER_MODE,
    base: process.env.BASE_URL,
    routes,
});

export default router;
